﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;

using Wiki.Web.Models;

namespace Wiki.Web.Views.Page
{
    public partial class TxtRepresentation : ViewPage<WikiPage>
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (this.ViewData.IsAvailable)
            {
                Response.ContentType = "text/plain";
                Response.AddHeader("Content-Language", "en");
                Response.AddHeader("Content-Location", Request.Url.OriginalString.Replace(".txt", String.Empty));

                Response.Cache.SetCacheability(HttpCacheability.Public);
                Response.Cache.SetLastModified(this.ViewData.LastModified.Value);

                Response.Write(this.ViewData.Body);
            }
            else
            {
                Response.StatusCode = 404; // Not Found
            }
        }
    }
}